package com.lmk.homework.work01;

public class CheckAccount extends Account{

   private  double overdraft;

    public double getOverdraft() {
        return overdraft;
    }

    public void setOverdraft(double overdraft) {
        this.overdraft = overdraft;
    }

    public CheckAccount(int id, double balance, double annualInterestRate, double overdraft) {
        super(id, balance, annualInterestRate);
        this.overdraft = overdraft;
    }
    public void deposit(double amount) {

        if (amount < getBalance()) {
            double am = getBalance() - amount;
            balance = am;
            System.out.println("您的账户余额为：" + balance);
            System.out.println("您的可透支额为：" + getOverdraft());
        }
        if (amount > getBalance()) {

            if (amount < getBalance() + getOverdraft()) {

                double Over = getBalance() + getOverdraft() - amount;
                setBalance(0);
                overdraft = Over;
                System.out.println("您的账户余额为：" + getBalance());
                System.out.println("您的可透支额为：" + overdraft);
            } else {
                System.out.println("超过可透支额！");
                System.out.println("您的可透支额为：" + overdraft);
            }
        }
    }}
